package com.example.wnn;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class Test {

    public static void main(String[] args) throws UnsupportedEncodingException {

        System.out.println(System.currentTimeMillis());
    }


    /**
          * 当前日期加上天数后的日期
          * @param num 为增加的天数
          * @return
          */
         public static String plusDay(int num){
                Date d = new Date();
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                String currdate = format.format(d);
                System.out.println("现在的日期是：" + currdate);

                Calendar ca = Calendar.getInstance();
                ca.add(Calendar.DATE, num);// num为增加的天数，可以改变的
                d = ca.getTime();
                String enddate = format.format(d);
                System.out.println("增加天数以后的日期：" + enddate);
                return enddate;
            }

    public static String decodeBase64(String content) throws UnsupportedEncodingException {
        if (StringUtils.isNotBlank(content)) {
            Base64 base64 = new Base64();
            return new String(base64.decode(content.getBytes()));
        }

        return "";
    }

    private static String adapterUnmobile(String hdUserId) {
        String result  = "11"+hdUserId;
        int i = 11- result.length();
        if (i>1){
            for (int j = 0; j < i; j++) {
                result+="0";
            }
        }
        System.out.println(result);
        return result;
    }


    private static void readTxt(){
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader("/Users/wenzheng/Desktop/plxx.txt"))) {
            String line;
            System.out.println("[");
            while ((line = bufferedReader.readLine())  != null) {
                // 处理每一行数据 .....
                if (StringUtils.isNotBlank(line)){
                    line ="\""+line+"\",";
                    System.out.println(line);
                }

            }
            System.out.println("]");

        } catch (Exception e) {
        }
    }


    //计算百分比
    public static String percent(int x, int y) {
        String percent = "";
        double xx = x * 100.0;
        double yy = y * 100.0;
        double zz = xx / yy;
        DecimalFormat df = new DecimalFormat("##.00%");
        if(Math.abs(zz)<0.000000000001){
            percent = "0.00%";
        } else {
            percent = df.format(zz);
        }
        return percent;
    }
    public static List<Integer> strToList(String var){
        if (StrUtil.isBlank(var)){
            return null;
        }
        List<String> v = Arrays.asList(var.split(","));
        List<Integer> result = new ArrayList<>();
        for (String s : v) {
            result.add(Integer.valueOf(s));
        }
        return result;
    }

    public static boolean is99cms(String rmtId) {
        if (StringUtils.isEmpty(rmtId)) {
            return false;
        }
        if (rmtId.contains("99cms_")) {
            return true;
        } else {
            return false;
        }
    }
}


